package io.renren.modules.course.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.course.dao.CourseSmallClassificationDao;
import io.renren.modules.course.dao.CourseSmallDao;
import io.renren.modules.course.entity.CourseSmallClassification;
import io.renren.modules.course.entity.CourseSmallEntity;
import io.renren.modules.course.service.CourseSmallClassificationService;
import io.renren.modules.course.service.CourseSmallService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("courseSmallClassificationService")
public class CourseSmallClassificationServiceImpl extends ServiceImpl<CourseSmallClassificationDao, CourseSmallClassification> implements CourseSmallClassificationService {

    @Autowired
    CourseSmallClassificationDao  courseSmallClassificationDao;

    @Override
    public List<CourseSmallClassification> getCourseSmallClassification(int id) {

        List<CourseSmallClassification> firstClassificationList =courseSmallClassificationDao.getCourseSmallClassification(id);

        for(CourseSmallClassification courseSmallClassification : firstClassificationList){

            List<CourseSmallClassification> secondClassificationList = this.getCourseSmallClassification(courseSmallClassification.getId());

            if(secondClassificationList.size() !=0){
                courseSmallClassification.setChildClassificationList(secondClassificationList);
            }
        }

        return firstClassificationList;
    }

    @Override
    public List<CourseSmallClassification> getAllCourseSmallClassification() {
        return courseSmallClassificationDao.getAllCourseSmallClassification();
    }

}
